(define (mdc a b)
  (if (= b 0)
      a
      (mdc b (remainder a b))))

; Applicative-order evaluation: avalia os parâmetros antes de substituir
;(mdc 206 40)
;(mdc 40 (remainder 206 40))
;(mdc 40 6)
;(mdc 6 (remainder 40 6))
;(mdc 6 4)
;(mdc 4 (remainder 6 4))
;(mdc 4 2)
;(mdc 2 (remainder 4 2))
;(mdc 2 0)
;2
; Resposta: calcula remainder 4 vezes

; Normal-order evaluation: substitui tudo antes de avaliar os parâmetros
(mdc 206 40)
(if (= 40 0) ...)
(mdc 40 (remainder 206 40)) ; 40 6
(if (= (remainder 206 40) 0) ...)
(if (= 6 0) ...)
; DUVIDA: Ao avaliar b para o if, ele já guarda o valor de b? Ou continua na ignorância?
; Assumindo que não guarda o valor então:
(mdc (remainder 206 40) (remainder 40 (remainder 206 40))) ; 6 4
(if (= (remainder 40 (remainder 206 40)) 0) ...)
(if (= (remainder 40 6) 0) ...)
(if (= 4 0) ...)
(mdc (remainder 40 (remainder 206 40)) (remainder (remainder 206 40) (remainder 40 (remainder 206 40)))) ; 4 2
(if (= (remainder (remainder 206 40) (remainder 40 (remainder 206 40))) 0) ...)
(if (= (remainder 6 (remainder 40 (remainder 206 40))) 0) ...)
(if (= (remainder 6 (remainder 40 6)) 0) ...)
(if (= (remainder 6 4) 0) ...)
(if (= 2 0) ...)
(mdc (remainder (remainder 206 40) (remainder 40 (remainder 206 40))) (remainder (remainder 40 (remainder 206 40)) (remainder (remainder 206 40) (remainder 40 (remainder 206 40))))) ; 2 0
(if (= (remainder (remainder 40 (remainder 206 40)) (remainder (remainder 206 40) (remainder 40 (remainder 206 40)))) 0) ...)
(if (= (remainder (remainder 40 6) (remainder (remainder 206 40) (remainder 40 (remainder 206 40)))) 0) ...)
(if (= (remainder 4 (remainder (remainder 206 40) (remainder 40 (remainder 206 40)))) 0) ...)
(if (= (remainder 4 (remainder 6 (remainder 40 (remainder 206 40)))) 0) ...)
(if (= (remainder 4 (remainder 6 (remainder 40 6))) 0) ...)
(if (= (remainder 4 (remainder 6 4)) 0) ...)
(if (= (remainder 4 2) 0) ...)
(if (= 0 0) ...)
(remainder (remainder 206 40) (remainder 40 (remainder 206 40)))
(remainder 6 (remainder 40 (remainder 206 40)))
(remainder 6 (remainder 40 6))
(remainder 6 4)
2
; Resposta: aplica remainder 18 vezes
